﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Ccit.OA.Notify
{
    public partial class notify_manage_querylist : Ccit.Utils.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            { _hidType.Value = (null != Request.QueryString["Type"]) ? Request.QueryString["Type"].ToString() : ""; }
            DataBindn();
        }
        /// <summary>
        /// grid 绑定
        /// </summary>
        private void DataBindn()
        {
            NotifyBLL Bll = new NotifyBLL();
           DataSet dSet = Bll.GetQueryMessage(_hidType.Value);
           if (dSet.Tables[0].Rows.Count > 0)
           {
               dgMain.DataSource = dSet;
           }
           else {
               dgMain.DataSource = null;
           }
            dgMain.DataBind();
        } 
        protected void dgMain_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
        {
            if (e.RowType != DevExpress.Web.ASPxGridView.GridViewRowType.Data) return;
            string sRecid = dgMain.GetRowValues(e.VisibleIndex, "queryid").ToString();
            string queryname = dgMain.GetRowValues(e.VisibleIndex, "queryname").ToString();  
            HtmlAnchor lnbDel = (HtmlAnchor)dgMain.FindRowCellTemplateControl(e.VisibleIndex, null, "lnbDel");
            lnbDel.Attributes["href"] = "javascript:doDelete('" + sRecid + "')";
            e.Row.Cells[0].Text = "<a href=\"javascript:Operate('" + sRecid + "')\">"+queryname+"</a>";
        }
        [global::System.Web.Services.WebMethod]
        public static string DoOperate(string QueryId)
        {
            NotifyBLL BLL = new NotifyBLL();
            string iNum = BLL.DoOperateQuery(QueryId);
            BLL = null;
            return iNum;
        }

        protected void lnbQuery_Click(object sender, EventArgs e)
        {
            DataBindn();
        }
    }
}
